home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2002 #4 / K-CD-4-2002.ISO / Empire Earth / EEDemo.exe / Disk1 / data.ssa / unit ai scripts_citizen.tai < prev    next >
Encoding:
Text File  |  2001-09-29  |  3.7 KB  |  140 lines

  1. //
  2. // Citizen unit AI file
  3. //
  4. // Behaviors:
  5. //
  6. //        If given an order to gather, continue to do so until there are no more resources within
  7. //                 the visibility map and wander range.
  8. //        If not gathering resources, keep an eye out for enemy units, pursue and attack if spotted.
  9. //        If Idle, Gathering Resources, or Moving and Taking damage, flee to the nearest
  10. //                 Town Center.
  11. //
  12. //    Notes:
  13. //
  14. //        At some point, need to have citizen search for something to do if idle.
  15. //        Add transition from Idle when enemies spotted to flee.
  16. //
  17. //    Known Problems:
  18. //
  19.  
  20.  
  21. ////////////////////////
  22. // Resource Gathering //
  23. ////////////////////////
  24.  
  25. #include("Gather.tai")
  26.  
  27.  
  28. //////////////////////////
  29. // Building & Repairing //
  30. //////////////////////////
  31.  
  32. // assumption here is that there are still some waypoints left
  33. CheckBuildSiteValidity
  34. {
  35.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  36.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  37.     BuildSiteValid true(Advance) false(CheckOwner)
  38. }
  39.  
  40. // assumption here is that there are still some waypoints left
  41. CheckBuildSiteVisibility
  42. {
  43.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  44.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  45.     BuildSiteVisible true(CheckBuildSiteValidity) false(Advance)
  46. }
  47.  
  48. CheckOwner
  49. {
  50.     OwnerIsHuman true(ConvertToLocationGoal)
  51.     OwnerIsComputer true(WaitForBuildSiteToClear)
  52. }
  53.  
  54. // assumption here is that there are no more waypoints
  55. CheckRepairSiteAccessibility
  56. {
  57.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  58.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  59.     RepairIsSpecialUnit true(ChangeTargetForSpecialRepair)
  60.     RepairSiteInRange false(Idle)
  61.     BuildSiteValid true(WaitForBuildSiteToClear) false(CheckOwner)
  62.     NextWaypointRetrieved false(PrepareToMove)
  63. }
  64.  
  65. ConvertToLocationGoal
  66. {
  67.     GoalIsLocation true(PrepareToMove)
  68. }
  69.  
  70. MoveToRepairSite
  71. {
  72.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  73.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  74.     RepairSiteInRange false(PrepareToMove)
  75.     BuildSiteValid true(WaitForBuildSiteToClear) false(ConvertToLocationGoal)
  76. }
  77.  
  78. ReacquireGoal
  79. {
  80.     GoalIsRepairSite true(CheckRepairSiteAccessibility)
  81. }
  82.  
  83. RepairBuilding
  84. {
  85.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  86.     anyof(BuildingRepaired,BuildingDestroyed) true(Idle)
  87.     anyof(CannotAffordRepair,BuildingNotPaidFor) true(InsufficientResources)
  88.     allof(TakingLightDamage,OwnerIsComputer) true(UnderAttack)
  89. }
  90.  
  91. InsufficientResources
  92. {
  93.     AlwaysTrue true(Idle)
  94. }
  95.  
  96. ChangeTargetForSpecialRepair
  97. {
  98.     AlwaysTrue true(MoveToRepairSite)
  99. }
  100.  
  101. TaskSmartCitizen
  102. {
  103.     SmartTaskNotAssigned true(Idle)
  104. }
  105.  
  106. WaitForBuildSiteToClear
  107. {
  108.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  109.     anyof(BuildingRepaired,BuildingDestroyed) true(Idle)
  110.     RepairIsSpecialUnit true(ChangeTargetForSpecialRepair)
  111.     BuildSiteClear true(RepairBuilding)
  112. }
  113.  
  114.  
  115. //////////////////
  116. // Other Stuff //
  117. /////////////////
  118.  
  119. Idle
  120. {
  121.     BuildingInBuildQueue true(MoveToRepairSite)
  122.     TakingLightDamage true(FleeDanger)
  123. }
  124.  
  125. #include("Generic Attack.tai")
  126.  
  127. // important that this go BEFORE including generic movement
  128. GetNextMoveWaypoint
  129. {
  130.     allof(GoalIsResource,ResourceTargetIsTree,ResourceInRange) true(GatherResource)
  131.     allof(GoalIsStorage,StorageInRange) true(AddResourceToStorage)
  132.     ShouldMoveToNextAutoWaypoint true(GetNextAutoWaypoint)
  133.     allof(GoalIsRepairSite,NextWaypointRetrieved) true(CheckBuildSiteVisibility)
  134.     allof(GoalIsWaitingArea,CanUseThisTileAsWaitingArea) true(MoveToWaitingArea)
  135. }
  136.  
  137. #include("Generic Movement.tai")
  138.  
  139. #include("Generic Death.tai")
  140.